<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('维保项目合同列表')" />
    <link rel="stylesheet" href="../../../../../../../../../../../../css/navigation.css">
</head>
<body class="gray-bg">
    <div class="navigation visible-xs-block">
        <ol class="breadcrumb">
            <span> > </span>
            <li><a href="#" onclick="gomain()">主页</a></li>
            <li><a href="#" onclick="buildformoney()">维保费用收入列表</a></li>
            <li class="last">维保项目合同列表</li>
        </ol>
        <div class="aLine"></div>
    </div>

     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId" th:object="${mtId}">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>合同名称：</label>
                                <input type="text" name="mtContractName"/>
                            </li>
<!--                            <li>-->
<!--                                <label>维保合同上传：</label>-->
<!--                                <input type="text" name="mtContractUpload"/>-->
<!--                            </li>-->
<!--                            <li>-->
<!--                                <label>维保费用金额：</label>-->
<!--                                <input type="text" name="mtPrice"/>-->
<!--                            </li>-->
<!--                            <li>-->
<!--                                <label>付款方式：</label>-->
<!--                                <input type="text" name="mtPayMethod"/>-->
<!--                            </li>-->
                            <li class="select-time">
                                <label style="width: 150px;">维保合同起始日期：</label>
                                <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginMtContractDate]"/>
                                <span>-</span>
                                <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endMtContractDate]"/>
                            </li>
<!--                            <li>-->
<!--                                <label>维保费发票是/否开具：</label>-->
<!--                                <select name="mtInvoiceStatus">-->
<!--                                    <option value="">所有</option>-->
<!--                                </select>-->
<!--                            </li>-->
<!--                            <li>-->
<!--                                <label>维保费发票是/否送至甲方并签收：</label>-->
<!--                                <input type="text" name="mtInvoiceSignfor"/>-->
<!--                            </li>-->
<!--                            <li>-->
<!--                                <label>维保费发票上传：</label>-->
<!--                                <input type="text" name="mtInvoiceUpload"/>-->
<!--                            </li>-->
                            <li>
                                <input type="hidden" name="mtId" th:value="${mtId}"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-warning" onclick="$.table.exportExcel(mstId)" shiro:hasPermission="ruoyi:contacts:export">
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script src="../../../../../../../../../../../../js/breadcrumb.js"></script>
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('ruoyi:contact:edit')}]];
        var removeFlag = [[${@permission.hasPermi('ruoyi:contact:remove')}]];
        var prefix = ctx + "ruoyi/contacts";
        var mstId=[[*{mtId}]];
        var mtInvoiceStatus = [[${@dict.getType('invoice_status')}]];
        var mtInvoiceSignfor = [[${@dict.getType('signfor_status')}]];
        $(function() {
            var options = {
                url: prefix + "/lists",
                exportUrl: prefix + "/export/"+mstId,
                modalName: "维保项目合同",
                method: 'post',
                sidePagination: "server",
                showFooter:true,
                showColumns: false,
                contentType: "application/x-www-form-urlencoded",
                queryParams: {
                    mtId:mstId
                },
                columns: [
                {
                    field: 'mtContractId', 
                    title: '主键id',
                    visible: false
                },
                {
                    field: 'mtContractName', 
                    title: '合同名称'
                },

                {
                    field: 'mtPrice', 
                    title: '维保费用金额',
                     footerFormatter: function(value){
                        var sum = 0;
                        for (var i in value) {
                            sum += parseFloat(value[i].mtPrice)
                        }
                        return "维保费用总金额: ￥"+sum;
                    }
                },
                {
                    field: 'mtPayMethod', 
                    title: '付款方式'
                },

                {
                    field: 'mtInvoiceStatus', 
                    title: '维保费发票开具',
                    align: "center",
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(mtInvoiceStatus, value);
                    }
                },
                {
                    field: 'mtInvoiceSignfor', 
                    title: '甲方签收维保费发票',
                    align: "center",
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(mtInvoiceSignfor, value);
                    }
                },
                    {
                        field: 'mtContractUpload',
                        title: '维保合同',
                        align: "center",
                        formatter: function(value, row, index) {
                            return '<a href="javascript:downloadFile(\''+row.mtContractUpload+'\')">下载</a>';
                        },
                    },
                {
                    field: 'mtInvoiceUpload',
                    title: '维保费发票',
                    align: "center",
                    formatter: function(value, row, index) {
                        var actions = [];
                        if(row.mtInvoiceUpload==null){
                            actions.push('未上传');
                            return actions.join('');
                        }else{
                            return '<a href="javascript:downloadFile(\''+row.mtInvoiceUpload+'\')">下载</a>';
                        }
                    },
                },
                    {
                        field: 'mtContractDate',
                        title: '维保合同起始日期'
                    },
                {
                    field: 'mtId', 
                    title: '伪外键',
                    visible: false
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="clickss(\'' + row.mtContractId + '\')"><i class="fa fa-edit"></i>维保项目金额</a> ');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
        function downloadFile(pUploading) {
            window.location.href=ctx+"common/download/resource?resource="+pUploading;
        }

        function clickss(mtContractId) {
            var urls = ctx + "ruoyi/priceing/price/"+mtContractId;
            $.modal.openTab("维保项目金额",urls);
        }
    </script>
</body>
</html>